{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/export/anaconda3/envs/vearch_cluster_langchain/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n",
      "Loading checkpoint shards: 100%|██████████| 7/7 [00:06<00:00,  1.03it/s]\n"
     ]
    }
   ],
   "source": [
    "from langchain.document_loaders import TextLoader\n",
    "from langchain.embeddings.huggingface import HuggingFaceEmbeddings\n",
    "from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
    "from transformers import AutoModel, AutoTokenizer\n",
    "from langchain.vectorstores.vearch import Vearch\n",
    "\n",
    "# repalce to your local model path\n",
    "model_path =\"/data/zhx/zhx/langchain-ChatGLM_new/chatglm2-6b\"  \n",
    "\n",
    "tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)\n",
    "model = AutoModel.from_pretrained(model_path, trust_remote_code=True).half().cuda(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Human: 你好!\n",
      "ChatGLM:你好👋！我是人工智能助手 ChatGLM2-6B，很高兴见到你，欢迎问我任何问题。\n",
      "\n",
      "Human: 你知道凌波微步吗，你知道都有谁学会了吗?\n",
      "ChatGLM:凌波微步是一种步伐，源自金庸先生的武侠小说《天龙八部》。段誉是学会凌波微步的人之一。\n",
      "\n"
     ]
    }
   ],
   "source": [
    "query = \"你好!\"\n",
    "response, history = model.chat(tokenizer, query, history=[])\n",
    "print(f\"Human: {query}\\nChatGLM:{response}\\n\")\n",
    "query = \"你知道凌波微步吗，你知道都有谁学会了吗?\"\n",
    "response, history = model.chat(tokenizer, query, history=history)\n",
    "print(f\"Human: {query}\\nChatGLM:{response}\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "No sentence-transformers model found with name /data/zhx/zhx/langchain-ChatGLM_new/text2vec/text2vec-large-chinese. Creating a new one with MEAN pooling.\n"
     ]
    }
   ],
   "source": [
    "# Add your local knowledge files\n",
    "file_path = \"/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/天龙八部/lingboweibu.txt\"#Your local file path\"\n",
    "loader = TextLoader(file_path,encoding=\"utf-8\")\n",
    "documents = loader.load()\n",
    "\n",
    "# split text into sentences and embedding the sentences\n",
    "text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=100)\n",
    "texts = text_splitter.split_documents(documents)\n",
    "\n",
    "#replace to your model path\n",
    "embedding_path = '/data/zhx/zhx/langchain-ChatGLM_new/text2vec/text2vec-large-chinese'\n",
    "embeddings = HuggingFaceEmbeddings(model_name=embedding_path)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['3556d6e803ff4c42b0d30cd2bb452ff2', '0079e8720dd546a3a3392e73009c3697', '95534c7b67cc4a4eb8244ca8541ec2af']\n",
      "***************after is cluster res*****************\n",
      "['-8844872069836508090', '-6664697494158621762', '149322492689170423']\n"
     ]
    }
   ],
   "source": [
    "#first add your document into vearch vectorstore\n",
    "vearch_standalone = Vearch.from_documents(\n",
    "    texts,embeddings,path_or_url=\"/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/valid_table\",table_name=\"valid_table\",flag=0)\n",
    "\n",
    "print(\"***************after is cluster res*****************\")\n",
    "\n",
    "vearch_cluster = Vearch.from_documents(\n",
    "    texts,embeddings,path_or_url=\"http://test-vearch-langchain-router.vectorbase.svc.ht1.n.jd.local\",db_name=\"valid_table_new_2\",table_name=\"valid_table_new_1\",flag=1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "####################第1段相关文档####################\n",
      "\n",
      "午饭过后，段誉又练“凌波微步”，走一步，吸一口气，走第二步时将气呼出，六十四卦走完，四肢全无麻痹之感，料想呼吸顺畅，便无害处。第二次再走时连走两步吸一口气，再走两步始行呼出。这“凌波微步”是以动功修习内功，脚步踏遍六十四卦一个周天，内息自然而然地也转了一个周天。因此他每走一遍，内力便有一分进益。\n",
      "\n",
      "这般练了几天，“凌波微步”已走得颇为纯熟，不须再数呼吸，纵然疾行，气息也已无所窒滞。心意既畅，跨步时渐渐想到《洛神赋》中那些与“凌波微步”有关的句子：“仿佛兮若轻云之蔽月，飘飘兮若流风之回雪”，“竦轻躯以鹤立，若将飞而未翔”，“体迅飞凫，飘忽若神”，“动无常则，若危若安。进止难期，若往若还”。\n",
      "\n",
      "\n",
      "\n",
      "百度简介\n",
      "\n",
      "凌波微步是「逍遥派」独门轻功身法，精妙异常。\n",
      "\n",
      "凌波微步乃是一门极上乘的轻功，所以列于卷轴之末，以易经八八六十四卦为基础，使用者按特定顺序踏着卦象方位行进，从第一步到最后一步正好行走一个大圈。此步法精妙异常，原是要待人练成「北冥神功」，吸人内力，自身内力已【颇为深厚】之后再练。\n",
      "\n",
      "####################第2段相关文档####################\n",
      "\n",
      "《天龙八部》第五回 微步縠纹生\n",
      "\n",
      "卷轴中此外诸种经脉修习之法甚多，皆是取人内力的法门，段誉虽自语宽解，总觉习之有违本性，单是贪多务得，便非好事，当下暂不理会。\n",
      "\n",
      "卷到卷轴末端，又见到了“凌波微步”那四字，登时便想起《洛神赋》中那些句子来：“凌波微步，罗袜生尘……转眄流精，光润玉颜。含辞未吐，气若幽兰。华容婀娜，令我忘餐。”曹子建那些千古名句，在脑海中缓缓流过：“秾纤得衷，修短合度，肩若削成，腰如约素。延颈秀项，皓质呈露。芳泽无加，铅华弗御。云髻峨峨，修眉连娟。丹唇外朗，皓齿内鲜。明眸善睐，靥辅承权。瑰姿艳逸，仪静体闲。柔情绰态，媚于语言……”这些句子用在木婉清身上，“这话倒也有理”；但如用之于神仙姊姊，只怕更为适合。想到神仙姊姊的姿容体态，“皎若太阳升朝霞，灼若芙蓉出绿波”，但觉依她吩咐行事，实为人生至乐，心想：“我先来练这‘凌波微步’，此乃逃命之妙法，非害人之手段也，练之有百利而无一害。”\n",
      "\n",
      "####################第3段相关文档####################\n",
      "\n",
      "《天龙八部》第二回 玉壁月华明\n",
      "\n",
      "再展帛卷，长卷上源源皆是裸女画像，或立或卧，或现前胸，或见后背。人像的面容都是一般，但或喜或愁，或含情凝眸，或轻嗔薄怒，神情各异。一共有三十六幅图像，每幅像上均有颜色细线，注明穴道部位及练功法诀。\n",
      "\n",
      "帛卷尽处题着“凌波微步”四字，其后绘的是无数足印，注明“妇妹”、“无妄”等等字样，尽是《易经》中的方位。段誉前几日还正全心全意地钻研《易经》，一见到这些名称，登时精神大振，便似遇到故交良友一般。只见足印密密麻麻，不知有几千百个，自一个足印至另一个足印均有绿线贯串，线上绘有箭头，最后写着一行字道：“步法神妙，保身避敌，待积内力，再取敌命。”\n",
      "\n",
      "段誉心道：“神仙姊姊所遗的步法，必定精妙之极，遇到强敌时脱身逃走，那就很好，‘再取敌命’也就不必了。”\n",
      "卷好帛卷，对之作了两个揖，珍而重之地揣入怀中，转身对那玉像道：“神仙姊姊，你吩咐我朝午晚三次练功，段誉不敢有违。今后我对人加倍客气，别人不会来打我，我自然也不会去吸他内力。你这套‘凌波微步’我更要用心练熟，眼见不对，立刻溜之大吉，就吸不到他内力了。”至于“杀尽我逍遥派弟子”一节，却想也不敢去想。\n",
      "\n",
      "********ChatGLM:凌波微步是一门极上乘的轻功，源于《易经》中的六十四卦。使用者需要按照特定顺序踏着卦象方位行进，从第一步到最后一步正好行走一个大圈。这门轻功精妙异常，可以让人内力大为提升，但需要谨慎练习，避免误用。据《天龙八部》记载，凌波微步是逍遥派独门轻功身法，段誉曾练过并深得其中的奥义。\n",
      "\n",
      "***************************after is cluster res******************************\n",
      "####################第1段相关文档####################\n",
      "\n",
      "午饭过后，段誉又练“凌波微步”，走一步，吸一口气，走第二步时将气呼出，六十四卦走完，四肢全无麻痹之感，料想呼吸顺畅，便无害处。第二次再走时连走两步吸一口气，再走两步始行呼出。这“凌波微步”是以动功修习内功，脚步踏遍六十四卦一个周天，内息自然而然地也转了一个周天。因此他每走一遍，内力便有一分进益。\n",
      "\n",
      "这般练了几天，“凌波微步”已走得颇为纯熟，不须再数呼吸，纵然疾行，气息也已无所窒滞。心意既畅，跨步时渐渐想到《洛神赋》中那些与“凌波微步”有关的句子：“仿佛兮若轻云之蔽月，飘飘兮若流风之回雪”，“竦轻躯以鹤立，若将飞而未翔”，“体迅飞凫，飘忽若神”，“动无常则，若危若安。进止难期，若往若还”。\n",
      "\n",
      "\n",
      "\n",
      "百度简介\n",
      "\n",
      "凌波微步是「逍遥派」独门轻功身法，精妙异常。\n",
      "\n",
      "凌波微步乃是一门极上乘的轻功，所以列于卷轴之末，以易经八八六十四卦为基础，使用者按特定顺序踏着卦象方位行进，从第一步到最后一步正好行走一个大圈。此步法精妙异常，原是要待人练成「北冥神功」，吸人内力，自身内力已【颇为深厚】之后再练。\n",
      "\n",
      "####################第2段相关文档####################\n",
      "\n",
      "《天龙八部》第五回 微步縠纹生\n",
      "\n",
      "卷轴中此外诸种经脉修习之法甚多，皆是取人内力的法门，段誉虽自语宽解，总觉习之有违本性，单是贪多务得，便非好事，当下暂不理会。\n",
      "\n",
      "卷到卷轴末端，又见到了“凌波微步”那四字，登时便想起《洛神赋》中那些句子来：“凌波微步，罗袜生尘……转眄流精，光润玉颜。含辞未吐，气若幽兰。华容婀娜，令我忘餐。”曹子建那些千古名句，在脑海中缓缓流过：“秾纤得衷，修短合度，肩若削成，腰如约素。延颈秀项，皓质呈露。芳泽无加，铅华弗御。云髻峨峨，修眉连娟。丹唇外朗，皓齿内鲜。明眸善睐，靥辅承权。瑰姿艳逸，仪静体闲。柔情绰态，媚于语言……”这些句子用在木婉清身上，“这话倒也有理”；但如用之于神仙姊姊，只怕更为适合。想到神仙姊姊的姿容体态，“皎若太阳升朝霞，灼若芙蓉出绿波”，但觉依她吩咐行事，实为人生至乐，心想：“我先来练这‘凌波微步’，此乃逃命之妙法，非害人之手段也，练之有百利而无一害。”\n",
      "\n",
      "####################第3段相关文档####################\n",
      "\n",
      "《天龙八部》第二回 玉壁月华明\n",
      "\n",
      "再展帛卷，长卷上源源皆是裸女画像，或立或卧，或现前胸，或见后背。人像的面容都是一般，但或喜或愁，或含情凝眸，或轻嗔薄怒，神情各异。一共有三十六幅图像，每幅像上均有颜色细线，注明穴道部位及练功法诀。\n",
      "\n",
      "帛卷尽处题着“凌波微步”四字，其后绘的是无数足印，注明“妇妹”、“无妄”等等字样，尽是《易经》中的方位。段誉前几日还正全心全意地钻研《易经》，一见到这些名称，登时精神大振，便似遇到故交良友一般。只见足印密密麻麻，不知有几千百个，自一个足印至另一个足印均有绿线贯串，线上绘有箭头，最后写着一行字道：“步法神妙，保身避敌，待积内力，再取敌命。”\n",
      "\n",
      "段誉心道：“神仙姊姊所遗的步法，必定精妙之极，遇到强敌时脱身逃走，那就很好，‘再取敌命’也就不必了。”\n",
      "卷好帛卷，对之作了两个揖，珍而重之地揣入怀中，转身对那玉像道：“神仙姊姊，你吩咐我朝午晚三次练功，段誉不敢有违。今后我对人加倍客气，别人不会来打我，我自然也不会去吸他内力。你这套‘凌波微步’我更要用心练熟，眼见不对，立刻溜之大吉，就吸不到他内力了。”至于“杀尽我逍遥派弟子”一节，却想也不敢去想。\n",
      "\n",
      "********ChatGLM:凌波微步是一种轻功身法，源于《易经》中的六十四卦。它通过按照特定顺序踏着卦象方位行进，从第一步到最后一步正好行走一个大圈，使内息自然而然地也转了一个周天。凌波微步可以锻炼身体的协调性和灵活性，增强身体的控制力和平衡感。凌波微步是逍遥派独门轻功身法，精妙异常，使用者需按照特定顺序踏着卦象方位行进，并达到一定的内力要求才能真正掌握这门轻功。在《天龙八部》中，段誉曾练凌波微步并精通其中之道。\n",
      "\n"
     ]
    }
   ],
   "source": [
    "query = \"你知道凌波微步吗，你知道都有谁会凌波微步?\"\n",
    "vearch_standalone_res=vearch_standalone.similarity_search(query, 3)\n",
    "for idx,tmp in enumerate(vearch_standalone_res): \n",
    "    print(f\"{'#'*20}第{idx+1}段相关文档{'#'*20}\\n\\n{tmp.page_content}\\n\")\n",
    "\n",
    "# combine your local knowleadge and query \n",
    "context = \"\".join([tmp.page_content for tmp in vearch_standalone_res])\n",
    "new_query = f\"基于以下信息，尽可能准确的来回答用户的问题。背景信息:\\n {context} \\n 回答用户这个问题:{query}\\n\\n\"\n",
    "response, history = model.chat(tokenizer, new_query, history=[])\n",
    "print(f\"********ChatGLM:{response}\\n\")\n",
    "\n",
    "print(\"***************************after is cluster res******************************\")\n",
    "\n",
    "query_c = \"你知道凌波微步吗，你知道都有谁会凌波微步?\"\n",
    "cluster_res=vearch_cluster.similarity_search(query_c, 3)\n",
    "for idx,tmp in enumerate(cluster_res): \n",
    "    print(f\"{'#'*20}第{idx+1}段相关文档{'#'*20}\\n\\n{tmp.page_content}\\n\")\n",
    "\n",
    "# combine your local knowleadge and query \n",
    "context_c = \"\".join([tmp.page_content for tmp in cluster_res])\n",
    "new_query_c = f\"基于以下信息，尽可能准确的来回答用户的问题。背景信息:\\n {context_c} \\n 回答用户这个问题:{query_c}\\n\\n\"\n",
    "response_c, history_c = model.chat(tokenizer, new_query_c, history=[])\n",
    "print(f\"********ChatGLM:{response_c}\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Human: 你知道vearch是什么吗?\n",
      "ChatGLM:是的，我知道 Vearch。Vearch 是一种基于矩阵分解的方法，用于解决线性方程组。它是一种高效的算法，特别适用于大规模线性方程组的求解。Vearch 算法将矩阵分解为基向量的叉积形式，这样可以快速地求解线性方程组。\n",
      "\n",
      "['029aa75548ff4f85908d089888fa84f4', '9e13390d56ce4cf08880579b3f6b340f', 'f7ee0b61bfe0476e988c19559f36d16f']\n",
      "*****************after is cluster res********************\n",
      "['-6632005459476004618', '-79270890206033064', '7036574374942192674']\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['-6632005459476004618', '-79270890206033064', '7036574374942192674']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "query = \"你知道vearch是什么吗?\"\n",
    "response, history = model.chat(tokenizer, query, history=history)\n",
    "print(f\"Human: {query}\\nChatGLM:{response}\\n\")\n",
    "\n",
    "vearch_info = [\"Vearch 是一款存储大语言模型数据的向量数据库，用于存储和快速搜索模型embedding后的向量，可用于基于个人知识库的大模型应用\",\n",
    "              \"Vearch 支持OpenAI, Llama, ChatGLM等模型，以及LangChain库\",\n",
    "              \"vearch 是基于C语言,go语言开发的，并提供python接口，可以直接通过pip安装\"]\n",
    "vearch_source=[{'source': '/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/tlbb/three_body.txt'},{'source': '/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/tlbb/three_body.txt'},{'source': '/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/tlbb/three_body.txt'}]\n",
    "vearch_standalone.add_texts(vearch_info,vearch_source)\n",
    "\n",
    "print(\"*****************after is cluster res********************\")\n",
    "\n",
    "vearch_cluster.add_texts(vearch_info,vearch_source)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "####################第1段相关文档####################\n",
      "\n",
      "Vearch 是一款存储大语言模型数据的向量数据库，用于存储和快速搜索模型embedding后的向量，可用于基于个人知识库的大模型应用\n",
      "\n",
      "####################第2段相关文档####################\n",
      "\n",
      "Vearch 支持OpenAI, Llama, ChatGLM等模型，以及LangChain库\n",
      "\n",
      "####################第3段相关文档####################\n",
      "\n",
      "vearch 是基于C语言,go语言开发的，并提供python接口，可以直接通过pip安装\n",
      "\n",
      "***************ChatGLM:是的，我知道 Vearch。Varch 是一款基于 C 语言和 Go 语言开发的向量数据库，旨在存储和快速搜索模型嵌入后的向量，可用于基于个人知识库的大模型应用。Varch 支持 OpenAI、Llama 和 ChatGLM 等模型，并提供了 Python 接口，用户可以通过 pip 安装。Varch 的特点是高可扩展性、高性能和易于使用。\n",
      "\n",
      "***************after is cluster res******************\n",
      "####################第1段相关文档####################\n",
      "\n",
      "Vearch 是一款存储大语言模型数据的向量数据库，用于存储和快速搜索模型embedding后的向量，可用于基于个人知识库的大模型应用\n",
      "\n",
      "####################第2段相关文档####################\n",
      "\n",
      "Vearch 支持OpenAI, Llama, ChatGLM等模型，以及LangChain库\n",
      "\n",
      "####################第3段相关文档####################\n",
      "\n",
      "vearch 是基于C语言,go语言开发的，并提供python接口，可以直接通过pip安装\n",
      "\n",
      "***************ChatGLM:是的，Vearch是一款存储大语言模型数据的向量数据库，用于存储和快速搜索模型embedding后的向量。它支持OpenAI，Llama，ChatGLM等模型，并且可以与LangChain库集成。Varch是一个基于C语言和Go语言开发的项目，并提供Python接口。通过pip安装，用户可以直接使用Varch进行数据存储和搜索。\n",
      "\n"
     ]
    }
   ],
   "source": [
    "query3 = \"你知道vearch是什么吗?\"\n",
    "res1 = vearch_standalone.similarity_search(query3, 3)\n",
    "for idx,tmp in enumerate(res1): \n",
    "    print(f\"{'#'*20}第{idx+1}段相关文档{'#'*20}\\n\\n{tmp.page_content}\\n\")\n",
    "\n",
    "context1 = \"\".join([tmp.page_content for tmp in res1])\n",
    "new_query1 = f\"基于以下信息，尽可能准确的来回答用户的问题。背景信息:\\n {context1} \\n 回答用户这个问题:{query3}\\n\\n\"\n",
    "response, history = model.chat(tokenizer, new_query1, history=[])\n",
    "print(f\"***************ChatGLM:{response}\\n\")\n",
    "\n",
    "print(\"***************after is cluster res******************\")\n",
    "\n",
    "query3_c = \"你知道vearch是什么吗?\"\n",
    "res1_c = vearch_standalone.similarity_search(query3_c, 3)\n",
    "for idx,tmp in enumerate(res1_c): \n",
    "    print(f\"{'#'*20}第{idx+1}段相关文档{'#'*20}\\n\\n{tmp.page_content}\\n\")\n",
    "\n",
    "context1_C = \"\".join([tmp.page_content for tmp in res1_c])\n",
    "new_query1_c = f\"基于以下信息，尽可能准确的来回答用户的问题。背景信息:\\n {context1_C} \\n 回答用户这个问题:{query3_c}\\n\\n\"\n",
    "response_c, history_c = model.chat(tokenizer, new_query1_c, history=[])\n",
    "\n",
    "print(f\"***************ChatGLM:{response_c}\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "delete vearch standalone docid True\n",
      "Human: 你知道vearch是什么吗?\n",
      "ChatGLM:Vearch是一种类似于\"vex\"的词汇,可能指的是一个数学或计算机科学中的符号或术语。在数学中,vearch可能指的是一个向量,其中每个元素都等于该向量在坐标轴上移动一个单位后的值。在计算机科学中,vearch可能指的是一个算法或数据结构,其中每个元素都包含有关另一个元素的信息。\n",
      "\n",
      " Vearch并不是一个常见的单词或术语,因此我无法提供更多信息。如果您有更多信息或上下文,可以提供更多信息,我将尽力回答您的问题。\n",
      "\n",
      "delete vearch cluster docid True\n",
      "Human: 你知道vearch是什么吗?\n",
      "ChatGLM:Vearch是一种高斯分布的概率分布,也称为高斯连结分布(Gaussian linking distribution)。它是基于高斯分布的一个变体,用于建模多个变量之间的关联关系,如时间序列中的多个状态或者空间中的多个位置。\n",
      "\n",
      "Vearch分布可以用于建模多个变量之间的因果关系,并且可以处理因变量是时间序列或实数的情况。它也被广泛用于金融和经济学等领域中,如股票价格和交易量等数据的建模。\n",
      "\n",
      "after delete docid to query again: {}\n",
      "get existed docid {}\n",
      "after delete docid to query again: {}\n",
      "get existed docid {}\n"
     ]
    }
   ],
   "source": [
    "##delete and get function need to maintian  docids \n",
    "##your docid\n",
    "\n",
    "\n",
    "res_d=vearch_standalone.delete(['029aa75548ff4f85908d089888fa84f4', '9e13390d56ce4cf08880579b3f6b340f', 'f7ee0b61bfe0476e988c19559f36d16f'])\n",
    "print(\"delete vearch standalone docid\",res_d)\n",
    "query = \"你知道vearch是什么吗?\"\n",
    "response, history = model.chat(tokenizer, query, history=[])\n",
    "print(f\"Human: {query}\\nChatGLM:{response}\\n\")\n",
    "\n",
    "res_cluster=vearch_cluster.delete(['-6632005459476004618', '-79270890206033064', '7036574374942192674'])\n",
    "print(\"delete vearch cluster docid\",res_cluster)\n",
    "query_c = \"你知道vearch是什么吗?\"\n",
    "response_c, history = model.chat(tokenizer, query_c, history=[])\n",
    "print(f\"Human: {query}\\nChatGLM:{response_c}\\n\")\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "get_delet_doc=vearch_standalone.get(['029aa75548ff4f85908d089888fa84f4', '9e13390d56ce4cf08880579b3f6b340f', 'f7ee0b61bfe0476e988c19559f36d16f'])\n",
    "print(\"after delete docid to query again:\",get_delet_doc)\n",
    "get_id_doc=vearch_standalone.get(['22f4c5e8af7541fb875b546872ef4e85', 'd796cdfe3ff7474e923bf87168f8788e', '738f7314b4134dd19e187b17968a379f'])\n",
    "print(\"get existed docid\",get_id_doc)\n",
    "\n",
    "get_delet_doc=vearch_cluster.get(['-6632005459476004618', '-79270890206033064', '7036574374942192674'])\n",
    "print(\"after delete docid to query again:\",get_delet_doc)\n",
    "get_id_doc=vearch_cluster.get(['6883964611486955620', '-3465968368475202129', '-4346376829616681721','3080506117063327914','7036574374942192674'])\n",
    "print(\"get existed docid\",get_id_doc)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.10.13 ('vearch_cluster_langchain')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "f1da10a89896267ed34b497c9568817f36cc7ea79826b5cfca4d96376f5b4835"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
